/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2020年1月13日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

/**
 * @Type A20200113_l122
 * @Desc
 * @author 52489
 * @date 2020年1月13日
 * @Version V1.0
 */
public class A20200113_l122 {
    public static void main(String[] args) {
        int nums[] = { 7, 1, 5, 3, 6, 4 };
        System.out.println(maxProfit_greedy(nums));
        ;
    }

    public static int maxProfit_greedy(int[] prices) {
        int maxProfit = 0;
        for (int i = 0; i < prices.length - 1; i++) {
            if (prices[i + 1] > prices[i]) {
                maxProfit = maxProfit + (prices[i + 1] - prices[i]);
            }
        }
        return maxProfit;
    }

    public static int maxProfit_DFS(int[] prices) {
        int maxProfit = 0;
        for (int i = 0; i < prices.length - 1; i++) {
            if (prices[i + 1] > prices[i]) {
                maxProfit = maxProfit + (prices[i + 1] - prices[i]);
            }
        }
        return maxProfit;
    }
}
